using Aurora.SingalR.Hubs;
using Microsoft.AspNetCore.SignalR;

namespace Gateway.UI.Api.Hubs;

/// <summary>
/// 
/// </summary>
public class HubHandlerProvider
{
     private readonly IHubHandler _hubHandler;
     private readonly IHubContext<MessageHub> _messageHub;

     /// <summary>
     /// 
     /// </summary>
     /// <param name="messageHub"></param>
     /// <param name="hubHandler"></param>
     public HubHandlerProvider(IHubContext<MessageHub> messageHub, IHubHandler hubHandler)
     {
          _messageHub = messageHub;
          _hubHandler = hubHandler;
     }

     /// <summary>
     /// 
     /// </summary>
     /// <param name="message"></param>
     public async Task Send(HubMessage message)
     {
          await _hubHandler.Send(_messageHub.Clients, message);
     }
}